#include "ti_msp_dl_config.h"

uint32_t count_speedL;
uint32_t count_speedR;
//4,294,967,295计数上限，电机100ms测速一次

void Encoder_Init(void)
{
    NVIC_EnableIRQ(GPIO_SPEED_INT_IRQN);
}

void GROUP1_IRQHandler(void)
{
    uint32_t trigger = DL_GPIO_getEnabledInterruptStatus(GPIOA,GPIO_SPEED_PIN_LA_PIN | GPIO_SPEED_PIN_RA_PIN);

    if(trigger & GPIO_SPEED_PIN_LA_PIN){
        if(DL_GPIO_readPins(GPIOB,GPIO_SPEED_PIN_LB_PIN)){
            count_speedL++;
        }
        else{
            count_speedL--;
        }

        DL_GPIO_clearInterruptStatus(GPIOA, GPIO_SPEED_PIN_LA_PIN);
    }

    if(trigger & GPIO_SPEED_PIN_RA_PIN){
        if(DL_GPIO_readPins(GPIOA,GPIO_SPEED_PIN_RB_PIN)){
            count_speedR++;
        }
        else{
            count_speedR--;
        }

        DL_GPIO_clearInterruptStatus(GPIOA, GPIO_SPEED_PIN_RA_PIN);
    }
}